#include<iostream>
#include<cstdio>
#include<stdio.h>
#include<cmath>
using namespace std;
long long n,l,r,i,s;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	if(r-l>=n-1)
		cout<<n-1;
	else
	{
	if(r-r%n>l)
	cout<<n-1;
	else
	{
		cout<<max(l%n,r%n);
	}
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
 } 
